#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Created 2011/12/01
@autor: Sérgio Santos
'''

import Tkinter
import tkMessageBox
import tkSimpleDialog
import urllib

from BeautifulSoup import BeautifulSoup

class calculate_html_tokens:

	def __init__(self):
   	
		root = Tkinter.Tk()
		root.withdraw()

		http_address = tkSimpleDialog.askstring('http address','Digite o http address? Example www.python.org ')	
		f = urllib.urlopen('http://'+str(http_address))
		s = f.read()
		soup = BeautifulSoup(s)
	
		h1 = soup.findAll('h1')
		h2 = soup.findAll('h2')
		h3 = soup.findAll('h3')
		div = soup.findAll('div')
		p = soup.findAll('p')
		ul = soup.findAll('ul')
		ol = soup.findAll('ol')
		self._h1 = len(h1)
		self._h2 = len(h2)
		self._h3 = len(h3)
		self._div = len(div)
		self._p = len(p)
		self._ul = len(ul)
		self._ol = len(ol)	  

		show_result_soup =tkMessageBox.showwarning(title='Test',
			message='H1 = '+str(self._h1)+' \nH2 = '+str(self._h2)+'\nH3 = '+str(self._h3)+' \ndiv = '+str(self._div)+'\nP = '+str(self._p)+'  \nUL = '+str(self._ul)+'\nOL = '+str(self._ol)+' ')
		
		root.destroy()
		
	
        pass
		
